//
//  Data.m
//  __PRODUCTNAME__
//
//  Created by LL.F on 16/08/30
//  Copyright (c) __ORGANIZATIONNAME__. All rights reserved.
//

#import "HomeData.h"
#import "Banner.h"
#import "Widgetlist.h"

@implementation HomeData

+ (NSDictionary *)objectClassInArray{
    return @{@"banner" : [Banner class], @"widgetList" : [Widgetlist class]};
}

- (void)setValue:(id)value forKey:(NSString *)key
{

    [super setValue:value forKey:key];
    if ([key isEqualToString:@"banner"]) {
        NSMutableArray<Banner *>  *bannerArray = [NSMutableArray array];
        for (NSDictionary *bannerDic in value) {
            Banner *banner = [Banner modelWithDic:bannerDic];
            [bannerArray addObject:banner];
        }
        _banner = bannerArray;
    }  if ([key isEqualToString:@"widgetList"]) {
        NSMutableArray<Widgetlist *>  *widgetlistArray = [NSMutableArray array];
        for (NSDictionary *widgetlistDic in value) {
            Widgetlist *widgetlist = [Widgetlist modelWithDic:widgetlistDic];
            [widgetlistArray addObject:widgetlist];
        }
        _widgetList = widgetlistArray;
    }
}
@end
